"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ColorEnum = void 0;
exports.getTextWithColor = getTextWithColor;
var ColorEnum;
exports.ColorEnum = ColorEnum;

(function (ColorEnum) {
  ColorEnum["BLACK"] = "\x1B[30m";
  ColorEnum["RED"] = "\x1B[31m";
  ColorEnum["GREEN"] = "\x1B[32m";
  ColorEnum["YELLOW"] = "\x1B[33m";
  ColorEnum["BLUE"] = "\x1B[34m";
  ColorEnum["MAGENTA"] = "\x1B[35m";
  ColorEnum["CYAN"] = "\x1B[36m";
  ColorEnum["WHITE"] = "\x1B[37m";
  ColorEnum["RESET"] = "\x1B[0m";
})(ColorEnum || (exports.ColorEnum = ColorEnum = {}));

function getTextWithColor(text, rules) {
  if (!Array.isArray(rules) || rules.length === 0) return text || '';
  if (!text) return '';
  var lable = text;
  rules.forEach(rule => {
    var {
      color,
      pattern
    } = rule;
    lable = lable.replace(pattern, word => {
      return "".concat(ColorEnum[color]).concat(word).concat(ColorEnum.RESET);
    });
  }); // const colorRule = rules.find((rule) => rule.validator(text));
  // if (colorRule) {
  //   return `${ColorEnum[colorRule.color]}${text}${ColorEnum.RESET}`;
  // }

  return lable;
}